﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
/// Summary description for LoginDL
/// </summary>
internal class LoginDL
{
    internal static bool CheckUser(LoginBL loginBL)
    {
        bool result = false;
        var user = OnlineTestHelper.Context.SP_CHECK_USER(loginBL.EmailId, loginBL.Password);
        foreach (var item in user)
        {            
            loginBL.FirstName = item.FIRST_NAME;
            loginBL.Gender = item.GENDER.Value;
            loginBL.LastName = item.LAST_NAME;
            loginBL.RoleName = item.ROLE_NAME;
            loginBL.UserId = item.USER_ID;                        
            result = true;
        }
        return result;
    }
    
    internal static bool Insert(LoginBL loginBL)
    {
        bool result = false;
        var user = OnlineTestHelper.Context.SP_INSERT_LOGIN(loginBL.EmailId, loginBL.Password, loginBL.FirstName, loginBL.LastName, loginBL.Gender, loginBL.RoleName);
        foreach (var item in user)
        {
            loginBL.FirstName = item.FIRST_NAME;
            loginBL.Gender = item.GENDER.Value;
            loginBL.LastName = item.LAST_NAME;
            loginBL.RoleName = item.ROLE_NAME;
            loginBL.UserId = item.USER_ID;
            result = true;
        }
        return result;
    }
}